package com.tangkeyon.common;

import com.google.common.collect.Sets;

import java.util.Set;

/**
 * @Author: tangkeyon@gmail.com
 * @Date: 2019/5/23 18:46
 * @Version 1.0
 */
public class Const {
    public static final String CURRENT_USER="currentUser";
    public static final String EMAIL="email";
    public static final String USERNAME="username";

    /**
     * 登录用户角色
    */
    public interface Role{
        int ROLE_CUSTOMER=0;
        int ROLE_ADMIN=1;
    }

    /**
     * 商品状态
     */
    public enum ProductStatus{
        ON_SAIL(1,"在售"),
        ;
        private int code;
        private String msg;

        ProductStatus(int code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public int getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }
    }

    /**
     * 动态排序依据
     */
    public interface OrderbyStatus {
        Set<String> PRICE_ASC_DESC= Sets.newHashSet("price_asc","price_desc");
    }

    /**
     * 购物车状态
     */
    public interface Cart{
        int CHECKED=1;
        int UNCHECKED=0;
        String LIMIT_NUM_FAIL="LIMIT_NUM_FAIL";
        String LIMIT_NUM_SUCCESS="LIMIT_NUM_SUCCESS";
    }

    /**
     * 订单状态
     */
    public enum OrderStatusEnum{
        CANCEL(0,"已取消"),
        NO_PAY(10,"未支付"),
        PAYED(20,"已支付"),
        SHIPPED(40,"已发货"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭"),;
        private int code;
        private String des;

        OrderStatusEnum(int code, String des) {
            this.code = code;
            this.des = des;
        }

        public int getCode() {
            return code;
        }
        public String getDes() {
            return des;
        }

        public static OrderStatusEnum codeOf(int code){
          for(OrderStatusEnum orderStatusEnum:values()){
              if(orderStatusEnum.getCode()==code)
                  return  orderStatusEnum;
          }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }

    /**
     * 支付宝回调状态
     */
    public interface AliPayCallBackStatus{
        String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
        String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";
        String RESPONSE_SUCCESS = "success";
        String RESPONSE_FAILED = "failed";
    }

    /**
     * 支付平台状态
     */
   public enum PayPlatformEnum{
       ALIPAY(1,"支付宝");
       ;
        private int code;
        private String des;

        PayPlatformEnum(int code, String des) {
            this.code = code;
            this.des = des;
        }

        public int getCode() {
            return code;
        }

        public String getDes() {
            return des;
        }}


    /**
     * 支付方式
     */
   public enum PaymentTypeEnum{
       ONLINE_PAY(1,"在线支付"),;
        private int code;
        private String des;

        PaymentTypeEnum(int code, String des) {
            this.code = code;
            this.des = des;
        }
        public int getCode() {
            return code;
        }
        public String getDes() {
            return des;
        }
        public static PaymentTypeEnum codeOf(int code){
            for(PaymentTypeEnum paymentTypeEnum:values()){
                if(paymentTypeEnum.getCode()==code)
                    return  paymentTypeEnum;
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
   }

}
